package com.vote.www.controller;

import com.vote.www.domain.vo.TUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 汤伟杰 on 2017/5/14.
 */
@Controller
@RequestMapping("/admin")
public class HomeController {


    @RequestMapping("/home.do")
    public String home(HttpServletRequest req, HttpServletResponse resp,
                        ModelMap model) {
        TUser user = (TUser) req.getSession().getAttribute("user");

       /* if(user==null){
            return "redirect:/approve/index.do";
        }*/
        return "home";
    }
    @RequestMapping("/login.do")
    public void index(HttpServletRequest req, HttpServletResponse resp,
                       ModelMap model) throws IOException {
        StringBuffer sb = new StringBuffer();
        sb.append("<!DOCTYPE html>\n");
        sb.append("<html lang=\"en\">\n");
        sb.append("<head>\n");
        sb.append("<meta charset=\"UTF-8\">\n");
        sb.append("<title>Title</title>\n" );
        sb.append("</head>\n");
        sb.append("<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n");
        sb.append("<script language='javascript'>top.location.href = '");
        sb.append(req.getContextPath()+"/approve/index.do");
        sb.append("'</script>\n");
        sb.append("</body>\n");
        sb.append("</html>");

        resp.getWriter().print(sb.toString());
    }
}
